<template>
  <div class="_wz_cent_main _wz_tryingStudy">
    <Card :bordered="true" style="margin:0 0 10px;">
      <p slot="title">隐患部位</p>
      <div class="_wz_releaseDeptList_cent1">
        <Row>
          <Col span="20">
            <div style="line-height: 30px;">
              隐患部位：<span>{{ !!selectDataParent.riskPositionName?selectDataParent.riskPositionName:'--' }}</span>
              隐患类型：
              <Tag color="success" type="dot" v-if="selectDataParent.riskPositionType == 1">基础管理</Tag>
              <Tag color="primary" type="dot" v-if="selectDataParent.riskPositionType == 2">设备设施</Tag>
              <Tag color="warning" type="dot" v-if="selectDataParent.riskPositionType == 3">作业活动</Tag>
              设施编号：<span>{{ !!selectDataParent.riskPositionDeviceNo?selectDataParent.riskPositionDeviceNo:'--' }}</span>
              是否特种设备：<span>{{ !!selectDataParent.riskPositionDeviceState ? '是' : '否' }}</span>
            </div>
            <div style="line-height: 30px;">
            责任人：<span>{{ !!selectDataParent.riskPositionUserName?selectDataParent.riskPositionUserName:'--' }}</span>
            责任部门：<span>{{ !!selectDataParent.riskPositionInOrgName?selectDataParent.riskPositionInOrgName:'--' }}</span>
            隐患区域：<span>{{ !!selectDataParent.riskPositionSiteLocation?selectDataParent.riskPositionSiteLocation:'--' }}</span>
            </div>
            <div style="line-height: 30px;">
              运输企业：<span>{{ !!selectDataParent.deptName?selectDataParent.deptName:'--' }}</span>
            </div>
            <div style="padding: 5px 0;">
              隐患描述：<span>{{ !!selectDataParent.riskPositionContext?selectDataParent.riskPositionContext:'--' }}</span>
            </div>
          </Col>
          <Col span="4">
            <div class="demo-upload-list">
              <viewer style="width: 100%;height: 100%;">
                <img :src="!!selectDataParent.riskPositionSiteImg ? apiUrl.imgUrl + selectDataParent.riskPositionSiteImg : '../../static/img/zwtpxd.png'" @error="public.imgDispose">
              </viewer>
            </div>
          </Col>
        </Row>



      </div>
    </Card>
    <Card :bordered="true" style="height: 100%;overflow: hidden;" class="_wz_indentation_ivu-table-wrapper">
      <p slot="title">列表</p>
      <p slot="extra">
        <Button type="primary" @click="addTableData">添加</Button>
      </p>
      <wzTbale ref="wzTbale" :tableData="tableData"></wzTbale>
    </Card>

    <Drawer width="600" v-model="formOperation" :title="formTitle" :draggable="true" :mask-closable="false" :styles="formOperationStyles">
      <tryingStudyAdd v-if="formOperation" :selectData="selectData" :selectDataParent="selectDataParent" @closeFun="closeFun"></tryingStudyAdd>
    </Drawer>

    <Spin size="large" fix v-if="spinShow"></Spin>
  </div>
</template>
<script>
import wzTbale from "../../components/table/table";
import tryingStudyAdd from "./tryingStudyAdd";
export default {
  props: ["selectDataParent"],
  components: {
    tryingStudyAdd,//
    wzTbale,//列表
  },
  data: function () {
    return {
      systemUserPageList:[],//人员list
      spinShow: false,//本页加载
      spinShow1:false,
      selectData: {},
      formTitle: "",
      formOperation: false,//表单左侧移出
      formOperationStyles: {//表单左侧移出css
        height: 'calc(100% - 55px)',
        overflow: 'auto',
        paddingBottom: '53px',
        position: 'static'
      },
      tableData: {
        url: this.apiUrl.riskPositionRiskPositionItemList,//请求地址
        method: 'post',//请求方式
        where: {riskPositionUuid: this.selectDataParent.uuid},//搜索条件
        height: '100%',//表格高度 auto
        page: false,//分页是否使用
        width: 100,
        columns: [//表头数据
          {type: 'index', width: 80, align: 'center', title: '序号'},
          {title: '隐患项目', minWidth: 140, key: 'riskPositionItemName'},
          {title: '责任人', minWidth: 120, key: 'riskPositionItemUserName'},
          {title: '责任部门', minWidth: 140, key: 'riskPositionItemInOrgName',indentation:true},
          {title: '检查标准', minWidth: 200, key: 'riskPositionItemCriterion',indentation:true},
          {title: '失控表现', minWidth: 200, key: 'riskPositionItemPerformance',indentation:true},
          {title: '管控措施', minWidth: 200, key: 'riskPositionItemMeasures',indentation:true},
          {title: '个人防护', minWidth: 200, key: 'riskPositionItemProtect',indentation:true},
          {title: '应急措施', minWidth: 200, key: 'riskPositionItemBurst',indentation:true},
          {
            title: '操作', fixed: 'right', width: 120,
            render: (h, params) => {
              var operationButtons = [];

              operationButtons.push(
                h('span', {
                  style: {"color": "#2d8cf0", "cursor": "pointer"},
                  on: {
                    click: () => {
                      this.formTitle = "修改"
                      this.selectData = JSON.parse(JSON.stringify(params.row));
                      this.formOperation = true;
                    }
                  }
                }, "修改")
              )
              operationButtons.push(h('Divider', {props: {type: 'vertical',}}, ''))
              operationButtons.push(
                h('span', {
                  style: {"color": "#2d8cf0", "cursor": "pointer"},
                  on: {
                    click: () => {
                      let that = this;
                      that.$Modal.confirm({
                        title: '删除提醒',
                        content: '确定要删除选中的数据？',
                        onOk: () => {
                          that.axios.post(that.apiUrl.riskPositionRiskPositionItemDelete, {uuid: params.row.uuid}).then(res => {
                            if (!!res) {
                              that.$Message.success('删除成功');
                              that.$refs.wzTbale.tableLoadData();
                            }
                          }).catch(err => {
                            console.log('失败', err);
                          })
                        },
                        onCancel: () => {
                        }
                      });
                    }
                  }
                }, "删除")
              )
              return operationButtons;
            }
          },
        ],
        format: {//返回数据格式
          list: ['data'],//数据list
          count: ['count'],//数据总量
        },
      }
    }
  },
  beforeCreate() {//beforeCreate创建前状态
  },
  created() {//created创建完毕状态
  },
  beforeMount() {//beforeMount挂载前状态   DOM 元素然后塞入页面的过程
  },
  mounted() {//mounted 挂载结束状态


  },
  methods: {//执行的方法
    //添加
    addTableData() {
      let that = this;
      that.formTitle = "添加";
      that.selectData = {
        riskPositionItemUserUuid:that.selectDataParent.riskPositionUserUuid,
        riskPositionItemInOrgUuid:that.selectDataParent.riskPositionInOrgUuid
      }
      that.formOperation = true;
    },
    //添加修改触发后关闭刷新
    closeFun(data) {
      var that = this;
      if (data) {//添加修改 刷新表单
        that.$refs.wzTbale.tableLoadData();
      }
      that.formOperation = false;
    },
  },
  watch: {//监听
  },
  beforeUpdate() {//beforeUpdate 更新前状态
  },
  updated() {//updated 更新完成状态
  },
  beforeDestroy() {//beforeDestroy 销毁前状态
  },
  destroyed() {//destroyed 销毁完成状态
  }
}
</script>


<style lang="less">
._wz_tryingStudy {
  //不固定头部  列表到底
  display: flex;
  flex-direction: column;
  height: 100%;
  .demo-upload-list {
    max-width: 100%;
    display: inline-block;
    width: 120px;
    height: 80px;
    text-align: center;
    line-height: 80px;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
    position: relative;
    border: 1px solid rgba(0, 0, 0, .2);
    margin-right: 4px;

    img {
      width: 100%;
      height: 100%;
    }
  }

  .ivu-card-body {
    height: calc(100% - 51px);
  }




  ._wz_releaseDeptList_cent1 {
    span {
      margin: 0 10px 0 0;
      color: #01AAED;
    }
  }
}

</style>


